//
//  SelectBudget.m
//  Bespoke
//
//  Created by Rafale Chang on 12/7/29.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "SelectBudget.h"
#import "SelectBudgetCell.h"

@implementation SelectBudget
@synthesize delegate;
@synthesize Array_budgetChoice;

- (void)initArray
{
    Array_budgetChoice = [[NSMutableArray alloc] init];
    [Array_budgetChoice addObject:@"Below $10,000 "];
    [Array_budgetChoice addObject:@"$10,001 to $20,000"];
    [Array_budgetChoice addObject:@"$20,001 to $30,000"];
    [Array_budgetChoice addObject:@"$30,001 to $40,000"];
    [Array_budgetChoice addObject:@"Above $40,000"];
}

#pragma mark - UITableViewDelegate

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"CE_choiceBudget";
    
    
    SelectBudgetCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    
    if(cell == nil)
    {
        NSArray *Array_nib = [[NSBundle mainBundle] loadNibNamed:@"SelectBudgetCell" owner:nil options:nil];
        
        cell = [Array_nib objectAtIndex:0];
        cell.Lab_Price.text = [Array_budgetChoice objectAtIndex:indexPath.row];
    }
    
    return cell;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [Array_budgetChoice count];
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [delegate BudgetDidSelected:[Array_budgetChoice objectAtIndex:indexPath.row]];
    [delegate uiViewTouched:NO ];
}

#pragma mark - Touches

- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event
{
    if( point.x > 0 && point.x < self.frame.size.width && point.y > 0 && point.y < self.frame.size.height )
    {
        [delegate uiViewTouched:YES ];
        return YES;
    }
    
    [delegate uiViewTouched:NO ];
    return NO;
}

@end
